package com.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mapper.CustomerReportMapper;
import com.qo.CustomerReportQuery;
import com.qo.QueryObject;
import com.service.CustomerReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Transactional
@Service
public class CustomerReportServiceImpl implements CustomerReportService {
    @Autowired
    private CustomerReportMapper customerReportMapper;

    public PageInfo selectCustomerReport(CustomerReportQuery qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        //查询结果使用 map 封装，字段名为 key，值为 value
        List<HashMap> list = customerReportMapper.selectCustomerReport(qo);
        return new PageInfo(list);
    }

    @Override
    public List<HashMap> listAll(CustomerReportQuery qo) {
        //不进行分页，但是还需要进行高级查询
        List<HashMap> list = customerReportMapper.selectCustomerReport(qo);
        return list;
    }
}
